package com.wxj.bank.mq.service.impl;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmListener;
import com.rabbitmq.client.Connection;
import com.wxj.bank.mq.service.IRabbitService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author shengtao
 * @Description: rabbitmq工具类
 * @date 2019/02/01 18:44
 */
@Service
public class RabbitServiceImpl implements IRabbitService{

    @Autowired
    private RabbitTemplate rabbitTemplate;

    void test() throws IOException {
        Connection connection = (Connection) rabbitTemplate.getConnectionFactory().createConnection();
        Channel channel = connection.createChannel();
        channel.txSelect();
        channel.txCommit();
        channel.addConfirmListener(new ConfirmListener() {
            @Override
            public void handleAck(long l, boolean b) throws IOException {

            }

            @Override
            public void handleNack(long l, boolean b) throws IOException {

            }
        });

    }

}
